import { Router } from 'vue-router'
import Progress from 'nprogress'

export function createPageLoadingGuard(router: Router): void {
  router.beforeEach(() => {
    Progress.start()
  })

  router.afterEach(() => {
    setTimeout(() => {
      Progress.done()
    }, 200)
  })

  router.onError(() => {
    Progress.done()
  })
}
